#include "ApplicationInfo.h"

#include <QtGui/QGuiApplication>
#include <QtGui/QScreen>
#include <QMessageBox>
#include <QtCore/QDebug>

ApplicationInfo::ApplicationInfo(QObject *parent) :
    QObject(parent)
{
    m_isMobile = false;
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS) || defined(Q_OS_BLACKBERRY)
    m_isMobile = true;
#endif

    qDebug()<< " @@@ ApplicationInfo is mobile " << m_isMobile ;

    m_constants = new QQmlPropertyMap(this);
    m_constants->insert(QLatin1String("isMobile"), QVariant(m_isMobile));
    m_constants->insert(QLatin1String("errorLoadingImage"), QVariant(tr("Error loading image - Host not found or unreachable")));

    QRect rect = qApp->primaryScreen()->geometry();
    qDebug()<< " @@@ ApplicationInfo is mobile " << rect.width() << " "<< rect.height();
    m_ratio = m_isMobile ? qMin(qMax(rect.width(), rect.height())/800. , qMin(rect.width(), rect.height())/480.) : 1;
    m_applicationWidth = m_isMobile ? rect.width() : 1120;


}

void ApplicationInfo::initData()
{
    // init signal - slot
    initSignalSlots();

    // show MainPage
    emit showMainPage();
}

void ApplicationInfo::initSignalSlots()
{

}

void ApplicationInfo::breakSignalSlots()
{

}
